import style from './index.module.scss'



const Heater = () => {
  var t = null;
  if (!document.querySelector(".showTime")) {
    return
  }
  t = setTimeout(time, 1000); //開始运行
  function time () {
    clearTimeout(t); //清除定时器
    var dt = new Date();
    var y = dt.getFullYear();
    var mt = dt.getMonth() + 1;
    var day = dt.getDate();
    var h = dt.getHours(); //获取时
    var m = dt.getMinutes(); //获取分
    var s = dt.getSeconds(); //获取秒    
    document.querySelector(".showTime").innerHTML =
      y +
      "年" +
      mt +
      "月" +
      day +
      "-" +
      h +
      "时" +
      m +
      "分" +
      s +
      "秒";
    t = setTimeout(time, 1000); //设定定时器，循环运行
  }
  return (
    <div className={style.header}>
      <div className={style.headerLeft} id="time"></div>
      <div className={style.headerCenter}>
        <div className={style.headerTitle}>
          大屏大数据展示示例
        </div>
        <div className={style.headerImg}></div>
      </div>
      <div className={`${style.headerRight} showTime`}></div>
      <div className={style.headerBottom}></div>
    </div>
  )
}

export default Heater